/* @INLINE FILE video.bloc.js =============================================================
	* video chat functions
	* 
	* VAR
	*
	* FUNC
	* this.c_Vs
	* this.closeVid
	* createVidID
	* guestsCanVideoChat
    * this.jsA
	* this.jsB
	* this.jsLV2
	* this.jsR
    * this.jsSt
    * this.jsStp
    * this.jsW
    * this.jsW2
    * this.jsV
    * this.launchChatWindow
    * this.launchVideoChat
    * this.launchVideoChatCont
    * this.removeAllStreams
    * returnBroadCastParams
    * this.subscribe
    * this.subscribePriv
	*/
    
    this.c_Vs=function(u){
 	   var dsp3 = _n;
        var dsp4 = _n;
        var margin = '15px';
        if (getCamVis(u)) {
            dsp3 = 'inline';
            dsp4 = 'inline';
            margin = '5px';
        }
        if (a.de[u] != null) {
            //$(a.de[u] + 'av').style.marginLeft = margin;
            $(a.de[u] + 'cam').style.display = dsp3;
        }
        if (a.gre[u] != '') {
           // $(a.gre[u] + 'av').style.marginLeft = margin;
            $(a.gre[u] + 'cam').style.display = dsp4;
        }
        if (a.pve[u] != '') {
            //$(a.pve[u] + 'av').style.marginLeft = margin;
            $(a.pve[u] + 'cam').style.display = dsp4;
        }
        if (a.wl[u] == '1' && a.vs[u] != '' && a.vs[u] != a.vsw[u]) {
     	   if(a.vsp[u]==1  || a.vcu[u]==_t.uid){
 	           var swf = gFL('fc_video');
 	           if (swf != null) {
 	               swf.startSubscription("rtmp://" + a.vs[u] + "/FCVideoChat1.2", createVidID(u), a.snm[u]);
 	           }
        	   }
            a.wl[u] == '0';
            a.vsw[u] = '';
        }
        if (a.wl2[u] == '1' && a.vs[u] != '' && a.vs[u] != a.vsw2[u]) {
     	   if(a.vsp[u]==1  || a.vcu[u]==_t.uid){
 		       var swf = gFL('fc_expand');
 		       if (swf != null) {
 		           swf.startSubscription("rtmp://" + a.vs[u] + "/FCVideoChat1.2", createVidID(u), a.snm[u]);
 		       }
     	   }
            a.wl2[u] == '0';
            a.vsw2[u] = '';
        }
 	};
 	
 	this.closeVid = function() {
    	try{
    		fc_ex.closeVid();
    	}catch(err){}
    };
	
	var createVidID =  function(u){
		u=u+'';
		var zeroes = '1';
        for (var i = 0; i < 8 - u.length; i ++ ) {
            zeroes += '0';
        }
        u = zeroes + u;
        u+=(chat_id.length>1?chat_id[0]:chat_id[0].substr(0,3));
		return u;
	};
	
	var guestsCanVideoChat = function(u){
    	if(is_guest(u)&&!config.guests_can_video_chat) {
        	showInfo(__(413,"Guests cannot video chat. Please sign in."));
    		return false;
        }
    	return true;
    };
    
    this.jsA = function(msg) {
        showInfo(msg);
    };
    
    this.jsB = function() {
        fc_ex.jsB(connection,_era)
    };
    
    this.jsLV2 = function(u) {
    	fc_ex.jsLV2(u,ww,videoAccountID,is_popup)
    };
    
    this.jsR = function(num) {
        fc_ex.jsR(num);
    };
    
    this.jsSt = function(id, uri) {
    	fc_ex.jsSt(id, uri, connection,_era)
    };
    
    this.jsStp = function(id) {
    	fc_ex.jsStp(id,connection,_era)
    };
    
    this.jsV = function() {
        $('fc_vidchat2').style.display = _n;
    };
    
    this.jsW = function(id, uri, add) {
    	fc_ex.jsW(id, uri, add)
    };
    
    this.jsW2 = function(id, uri, add) {
    	fc_ex.jsW2(id, uri, add)
    };
    
    this.launchChatWindow = function(u,priv) {
        if (fc_chat.ww2 == null &&! l) {
            l=true;
            var borderstyle = '1px solid #444444';
            var allowFixed =!is_popup&&!exp6&&config.pin_windows;
            var fixed = allowFixed&&config.pinned_by_default;
            var top = (_t.m==0&&ww?EN(ww.frame[0].style.top)+200:200);
            var scroll = jQ(document).scrollTop();
            if(ww){
            	top += (ww.fixed?scroll:0) + (fixed?-scroll:0);
            }else{
            	top += (!fixed?scroll:0);
            }
            var content="<div style='padding:10px;font-family:arial;font-size:14px;color:black;font-weight:bold'><div style='margin-top:55px;margin-left:100px;'>"+ __(329,"Loading...Please Wait")+"</div></div>";
            fc_chat.ww2 = fc_chat.createWidget('DefaultWindow',["<span style='"+config.styles.chat_window.frame.title_css+"'>" + __(152) + "</span>", 200, top, 368, 163, 'default', config.styles.chat_window.frame.color, config.styles.chat_window.frame.opacity*100, borderstyle, 'e3e3e3', '', 'html', content, false, false,siteLogo, __(154), __(155), __(156), __(157), __(315,"pin to screen"), __(316,"unpin"),allowFixed,(allowFixed?config.pinned_by_default:false)]);
            fc_chat.tg_vid=1;
            fc_chat.setPaused();
            fc_chat.ww2.mH = 38;
            fc_chat.ww2.MH = 800;
            fc_chat.ww2.close = function() {
        		this.getDefault().close.call(this);
                fc_chat.ww2=null;
                fc_chat.tg_vid=0;
                fc_chat.setPaused();
                invitePriv=false;
                return true;
            };
            fc_chat.ww2.maximize = function() {
            	this.lock=false;
            };
            if(!script_loaded){
        		extend_id=1;
        		extend();
        	}else{
        		fc_ex.initVideoChat(fc_chat.ww2,u,priv);
        		l=false;
        	}
        }
    };
    
    this.launchVideoChat = function(u,priv) {
    	if(!guestsCanVideoChat(_t.uid)) {
    		return;
        }
    	if(!l&&(!priv||((isAvl(priv)||priv==_t.uid)&&a.o[priv] == '1'))) {
	    	if((!priv && fc_chat.vidAcc>1) || (priv && fc_chat.vidAcc%2!=0)){
		    	if(streamCount > config.max_video_streams) {
		        	showInfo(__(228));
		    		return;
		        }
		    	if(priv&&is_guest(priv)&&!config.guests_can_video_chat) {
		        	showInfo(__(412,"Video chat is disabled for guest accounts."));
		    		return;
		        }
		    	if(!priv&&fc_chat.vidAcc>1 && (config.videoconerence_only_in_designated_rooms&&(!rooms[current_room]||rooms[current_room].v==1))){
		    		showInfo(__(225));
		    		return;
		    	}
		    	if(fc_chat.ww2 && (fc_chat.cvu_priv||priv) && priv !=fc_chat.cvu_priv){
		    		fc_chat.ww2.close();
		    	}
		    	//Set up variables u is the user you whose webcam you want to load, priv is the user the private chat
		    	//is directed to
		    	current_video_user=u;
		    	if(priv){
		    		fc_chat.cvu_priv=priv;
		    	}else{
		    		fc_chat.cvu_priv=null;
		    	}
		    	clearTimeout(tVid);
		    	tVid=setTimeout('fc_chat.launchChatWindow(' + u + ',' + priv + ')',250);
	    	}
    	}
    };
    
    this.launchVideoChatCont = function(u){
    	fc_ex.launchVideoChatCont(u,videoAccountID,connection,_era);
    };
    
    this.removeAllStreams = function() {
    	fc_ex.removeAllStreams(connection, _era)
    };
    
    function returnBroadcastParams(data) {
        fc_ex.returnBroadcastParams(data,_t.uid);
    };
    
    this.subscribe = function(u) {
    	if(!guestsCanVideoChat(_t.uid)) {
    		return;
        }
    	fc_ex.subscribe(u,_t.uid,streamCount,rooms,current_room)
    };
	
    this.subscribePriv = function(u) {
    	//check that user is online and broadcasting
    	if(!guestsCanVideoChat(_t.uid)) {
    		return;
        }
    	if(!(a.o[u] == '1'&&a.vcu[u] == _t.uid&&a.vs[u] != ''&&isAvl(u))){
    		showInfo(__(323),"Sorry, this user is not available for video chat at the moment.");
    	}else{
	    	if (streamCount <= config.max_video_streams) {
	            //load the chat window
	            fc_chat.launchVideoChat(u,u);
	        } else {
	            showInfo(__(228));
	        }
    	}
    };
 	
 	//video.bloc.js =============================================================@END FILE*/